<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的修炼</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <link href="/css/style.css" type="text/css" rel="stylesheet">
</head>
<body>

<br>

<#assign exp_up= (hero.level*1024) >
<#if hero.vigour<20 && hero.state==1 >
    <span style="color: #ff4d00">活力不足20，无法开始修炼！</span><br><br>
</#if>
<#if hero.state==2 >
    <#assign ct=((.now?long-hero.practiceStartTime?long)/1000)?int >
    <div id="practice_long" data="${ct}" remark="已经修炼多少秒"></div>
    正在修炼（<span id="xlsc"></span>）<a href="/game/practice/stop">结束修炼</a>
<#else >
    普通修炼:未修炼&#160;<a href="/game/practice/start">开始</a>
</#if>
<br><br>
等级：${hero.level}
<br><br>

经验: ${hero.exp} / ${exp_up}&#160;
<#if hero.exp gte exp_up >
    <a href="/game/upgrade">升级</a>
</#if>
<div class="progress-bar">
    <div style="width:${(hero.exp*100)/(hero.level*1024)}%; background:#82b700;"></div>
</div>
<br>

活力：${hero.vigour} / 100
<#if hero.vigourTime?string('yyyy-MM-dd') != .now?string('yyyy-MM-dd') >
    <a href="/game/replenish">补充活力</a>
<#else >
    &nbsp;[今日已领取]
</#if>
<br>
（每次修炼消耗20活力）

<br><br>
<#include "inc/menu.ftl" >

<br/>
<a href="javascript:history.go(-1);">上页</a>-<a href="">游戏首页</a>-<a href="">功能导航</a>-<a href="">关于</a><br/>

<#include "inc/footer.ftl" >

<#if hero.state==2 >
<script>

    (function () {
        function second_format(n) {
            var t = '';
            if (n >= 86400) {
                t += parseInt(n / 86400) + '天';
            }
            if (n >= 3600) {
                t += parseInt(n % 86400 / 3600) + '小时';
            }
            if (n >= 60) {
                t += parseInt((n % 3600) / 60) + '分';
            }
            t += parseInt(n % 60) + '秒';
            return t;
        }
        var el = document.getElementById('practice_long');
        var el2 = document.getElementById('xlsc');
        var len = Number(el.getAttribute('data')); //已经修炼了多久
        el2.innerHTML=second_format(len);
        var timer = window.setInterval(function () {
            len++;
            el.setAttribute('data', len);
            el2.innerHTML=second_format(len);
        }, 1000);
    })();
</script>
</#if>

</body>
</html>